<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String basepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style type="text/css">
.body_top>div {
	width: 870px;
	height: 85px;
	margin: 0 auto;
	padding-top: 10px;
}

.body_top>div>p {
	font-family: "微软雅黑";
	color: #90c624;
	font-size: 40px;
	font-weight: 900;
	display: inline-block;
}

.body_top>div>span {
	font-size: 14px;
	color: #8f8f8f;
	float: right;
	margin-top: 20px;
}

.body_top>div>img {
	float: right;
	margin: 17px 5px;
}

.body_top>div>div {
	display: inline-block;
}

.body_top>div>div>p {
	font-weight: 500;
	letter-spacing: 2px;
	font-size: 18px;
	color: #8f8f8f;
}

.body_top>div>div>.last_p {
	color: #90c624;
	font-size: 12px;
	letter-spacing: 0px;
}

.body_wrap {
	width: 100%;
	background: #f7f7f7;
	padding-top: 50px;
}

.body_wrap .middle {
	width: 870px;
	height: 630px;
	margin: 0 auto;
}

.body_wrap .middle .left {
	float: left;
	height: 630px;
}

.body_wrap .left_top {
	background: #90c624;
	width: 180px;
	height: 120px;
	color: #fff;
	padding-top: 20px;
	font-size: 20px;
	text-align: center;
}

.body_wrap .left_top .last_p {
	font-size: 16px;
}

.body_wrap .left_botton {
	width: 180px;
	height: 200px;
	background: #fff;
	font-size: 15px;
	color: #6d6d6d;
}

.body_wrap .left_botton>p>a {
	display: inline-block;
	padding: 10px 58px;
	text-decoration: none;
	color: #848482;
}

.body_wrap .left_botton>p>a:hover {
	background: #f0f0f0;
	border-left: 3px solid #96c720;
}

.p_click {
	background: #f0f0f0;
	border-left: 3px solid #96c720;
}

.body_wrap .right {
	float: left;
	width: 690px;
}

.right2, .right3 {
	display: none;
}
.body_wrap .right>div>p {
	color: #7f7f7f;
	font-size: 15px;
}

.body_wrap .right>div>p>img {
	float: right;
	margin: 10px;
}

.body_wrap .right>div>p>span {
	padding: 0px 5px;
	margin: 10px;
	background: #99c41d;
	color: #fff;
}

.body_wrap .right .hd {
	display: inline-block;
	width: 600px;
	display: none;
	margin-top: 15px;
}

.body_wrap .right .hd>span {
	background: #7e7e7e;
}
.ds{
	width: 200px;
	height: 110px;
	margin-left: 20px;
	margin-bottom: 20px;
	float: left;
	background: #b2d771;
	padding-top: 5px;
}

.ds .ds_left {
	width: 70px;
	height: 80px;
	margin-right: 8px;
	float: left;
	padding: 5px 5px 0px 5px;
}

.ds .ds_left img {
	width: 60px;
	height: 60px;
	border-radius: 5px;
}

.ds .ds_right {
	padding: 0px 6px;
	height: 80px;
	font-size: 13px;
}

.ds .ds_right p {
	text-align: left;
	line-height: 20px;
}

.ds .ds_right .remove {
	padding: 1px;
	border-radius: 15px;
	background:#90c624;
	color: #fff;
	float: right;
	cursor: pointer;
}

.ds .ds_bottom button {
	font-size: 12px;
	padding: 2px 5px;
	border: none;
	border-radius: 5px;
	background: #c3c3c5;
	float: right;
	margin-right: 10px;
}
#each_div{
	height: 570px;
}
</style>
<script>
<%if (request.getAttribute("pjax_back") != null && !request.getAttribute("pjax_back").equals("")) {%>
	<%=(String) request.getAttribute("pjax_back")%>
<%}%>
</script>
<div class="body_top">
	<div>
		<p>创业辅导</p>
		<div>
			<p>ENTERPRENEURIAL COUNSELING</p>
			<p class="last_p">THE BEAST PEOPLE FORMULA FOR GREAT WEBSITES</p>
		</div>
		<img src="img/btn.png"> <span>当前位置：<span>首页</span>><span>创业导师</span></span>
	</div>
</div>
<div class="body_wrap">
	<div class="middle">
		<div class="left">
			<div class="left_top">
				<p>ENTEPRENEURIAL</p>
				<p>COUNSELING</p>
				<p class="last_p">创业导师</p>
			</div>
			<div class="left_botton">
				<p>
					<a class="pjax" href="index_cyds?type=1">校内导师</a>
				</p>
				<p>
					<a class="pjax" href="index_cyds?type=2">校外导师</a>
				</p>
			</div>
		</div>
		<div class="right" id="main_right">
			<div id="each_div" title="1">
			<c:forEach items="${requestScope.lists }" var="tutor">
			<div class="ds">
				<div class="ds_left">
					<img
						src="${tutor.get(0).tu_logo != null ? tutor.get(0).tu_logo : 'img/tutor1.png'}">
				</div>
				<div class="ds_right">
					<p>姓名:${tutor.get(0).tu_name}</p>
					<p>邮箱:${tutor.get(0).tu_ctime }</p>
					<p>辅导方向:${tutor.get(1).gd_name }</p>
				</div>
				<div class="ds_bottom">
					<button>查看更多</button>
				</div>
			</div>
			</c:forEach>
		</div>
		<div class="fy" title="${sum != null?sum:1 }">
			<span id="pre_page">上一页</span>
			<ul>
			</ul>
			<span id="next_page">下一页</span>
		</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	
	 var kind="teac";
	    var type=location.search.split("?")[1];
	   /*  var sum =$("div.fy").attr("title"); */
	    var sum = 20;
	    var connect_page=0;
	    printList(1);
   function printList(index){
     var fy_html="";
     var show = sum-index>7?8:sum-index+1;
     if(index<=connect_page){
         for(var i=8;i>0;i--){
             fy_html+="<li>"+(index-i+1)+"</li>";
         }
         $(".fy>ul").html(fy_html);
         $(".fy>ul>li").eq(7).addClass('fy_on');
     }else{
         for(var i=0;i<show;i++){
             fy_html+="<li>"+(index+i)+"</li>";
         }
         $(".fy>ul").html(fy_html);
         $(".fy>ul>li").eq(0).addClass('fy_on');
     }
     connect_page=index;
     console.log(connect_page)
 }
	    //点击分页  分别触发ajax事件以及分页列表事件
	    $(".fy>ul").delegate('li','click',function(){
	        
	        $(this).addClass('fy_on');
	        $(this).siblings("li").attr("class","");
	        var page = $(this).html();
	        if(sum>8&&(page%7==1)&&page>7){
	            printList(Number(page));
	            }else{
	                connect_page=page;
	            }
	            connect_data(kind,page,type);
	            
	        })
	$("#pre_page").click(function(){
     var pre_page=(connect_page-1)%7;
     pre_page= pre_page==0?7:pre_page;
     $("div.fy>ul>li").eq(pre_page-1).trigger("click");
 });
 
  $("#next_page").click(function(){
     var next_page=(Number(connect_page)+1)%7;
      next_page= next_page==0?7:next_page ;
      next_page= next_page==1?8:next_page ;
     $("div.fy>ul>li").eq(next_page-1).trigger("click");
 }) 
 
	
 // 上一页  and 下一页

 function connect_data(kind,page,type){
     type= (type == undefined?"":"&&"+type);
     var address ="index_paging?html="+kind+type+"&&page="+page;
     console.log(address);
     getData(address,printNews)
 }
 // ajax传值取相应数据
 function getData(address,callback){
     $.ajax({
         type:"post",
         url:address,
         dataType:"json",
         success:function(data){
             callback(data);
         },
         error:function(e){
             alert(e.message);
         }
     });
 }
	        
	//回调函数渲染页面
	function printNews(data){
		var teac_html="";
		$.each(data.paging,function(){
			var that=this.list;
			teac_html+= "<div class='ds'><div class='ds_left'><img src='img/tutor1.png'/></div><div class='ds_right'><p>ID:"+that[0].tu_id+"</p><p>姓名:"+that[0].tu_name+"</p><p>登录名:"+that[0].tu_loname+"</p><p>电话:"+that[0].tu_tel+"</p><p>辅导方向:"+that[1].gd_name+"</p></div><div class='ds_bottom'><button>查看更多</button></div></div>";
		});
		$("#each_div").html(teac_html);
	}
})
</script>
